package com.itheima.listener;

import org.springframework.stereotype.Component;

@Component
public class AmqpListener {

//    //监听简单类型消息
//    @RabbitListener(queues = "p2p")//监听队列名称
//    public void listen1(String msg) {
//        System.out.println("消费者接收到了消息:" + msg);
//    }

//    //监听wintln("消费者1接收到了消息:" + msg);
//        Thread.sleep(200)ork类型消息
////    @RabbitListener(queues = "p2p")//监听队列名称
////    public void listen1(String msg) throws InterruptedException {
////        System.out.pr;
//    }
//
//    //监听work类型消息
//    @RabbitListener(queues = "p2p")//监听队列名称
//    public void listen2(String msg) throws InterruptedException {
//        System.err.println("消费者2接收到了消息:" + msg);
//        Thread.sleep(2000);
//    }

//    //监听fanout类型消息
//    @RabbitListener(queues = "fanout.queue1")//监听队列名称
//    public void listen1(String msg){
//        System.out.println("消费者1接收到了消息:" + msg);
//    }
//    @RabbitListener(queues = "fanout.queue2")//监听队列名称
//    public void listen2(String msg){
//        System.err.println("消费者2接收到了消息:" + msg);
//    }
//    //监听direct类型消息
//    @RabbitListener(bindings = @QueueBinding(
//            exchange = @Exchange(value = "direct.exchange",type = ExchangeTypes.DIRECT),//交换机名称和类型
//            value = @Queue(value = "direct.queue1"),//队列名称
//            key = {"china.news","china.weather"}//bindingKey
//    ))//监听队列名称
//    public void listen1(String msg){
//        System.out.println("消费者1接收到了消息:" + msg);
//    }
//
//        @RabbitListener(bindings = @QueueBinding(
//                exchange = @Exchange(value = "direct.exchange",type = ExchangeTypes.DIRECT),//交换机名称和类型
//                value = @Queue(value = "direct.queue2"),//队列名称
//                key = {"china.news","world.news"}//bindingKey
//        ))//监听队列名称
//        public void listen2(String msg){
//            System.err.println("消费者2接收到了消息:" + msg);
//        }
//
//    //监听topic类型消息
//    @RabbitListener(bindings = @QueueBinding(
//            exchange = @Exchange(value = "topic.exchange", type = ExchangeTypes.TOPIC),//交换机名称和类型
//            value = @Queue(value = "topic.queue1"),//队列名称
//            key = "china.#"//bindingKey
//    ))//监听队列名称
//    public void listen1(String msg) {
//        System.out.println("消费者1接收到了消息:" + msg);
//    }
//
//    @RabbitListener(bindings = @QueueBinding(
//            exchange = @Exchange(value = "topic.exchange", type = ExchangeTypes.TOPIC),//交换机名称和类型
//            value = @Queue(value = "topic.queue2"),//队列名称
//            key = "*.news"//bindingKey
//    ))//监听队列名称
//    public void listen2(String msg) {
//        System.err.println("消费者2接收到了消息:" + msg);
//    }

/*
    //监听简单类型消息
    @RabbitListener(queuesToDeclare = @Queue("object.queue"))//监听队列名称
    public void listen1(Map<String, Object> map) {
        System.out.println("消费者接收到了消息:" + map.get("name") + map.get("age"));
    }*/
}

